<?php /* Smarty version 2.6.20, created on 2012-06-20 16:35:54
         compiled from _core/pagecommon/_mvc/_control/handlepagebackendcontracts.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', '_core/pagecommon/_mvc/_control/handlepagebackendcontracts.tpl', 59, false),)), $this); ?>
function HandlePageBackendContracts(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options;
  
  this._createElements();
};

HandlePageBackendContracts.prototype._createElements = function() {
  //this._gui.add.style.display = 'none';
  this._loadData();
};

HandlePageBackendContracts.prototype._loadData = function() {
  var tr, td;
  tr = this._gui.result.insertRow(-1);
  td = tr.insertCell(-1);
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._contracts = null;
  this._retrieveContracts();
};

HandlePageBackendContracts.prototype._verifyData = function() {
  if (this._contracts) {
    this._updateElements();
  }
};

HandlePageBackendContracts.prototype._retrieveContracts = function(page, condition, date, from, to, pos) {
  var _self = this;
  /*new RequestUtils()._read('contract', null, null, null, null, 'd.orderType', null, function(result, params) { _self._contracts = result.data;
                                                                                                               _self._verifyData.call(_self);
                                                                                                             }, null);*/
  new RequestUtils()._mysql('contract', null, function(result, params) { _self._contracts = result.data;
                                                                          _self._parameters = result;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php',pos: (pos) ? pos : null });                                                                                                                 
};

HandlePageBackendContracts.prototype._updateElements = function() {
  var tr, td, _self = this;
  DOMUtils.removeTableRows(this._gui.result, 1);
  
  if (this._contracts.length == 0) {
    tr = this._gui.result.insertRow(-1);
    td = tr.insertCell(-1);
    td.colSpan = 3;
    td.style.height = '24px';
    td.style.textAlign = 'center';
    td.style.borderRight = 'solid 1px #694247';
    td.style.borderLeft = 'solid 1px #694247';
    td.style.borderBottom = 'solid 1px #694247';
    td.style.backgroundColor = '#fff';
    td.appendChild(document.createTextNode('N/A'));
  }  
    this._gui.add.style.display = 'block';
    this._gui.add.onclick = function() { if (_self._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_MANAGER_ASSISTANT)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
                                           location.href = '?p=pageasst&t=pagebackendcontract&m=' + JSON.stringify({ a: 5, b: 8 });
                                         } else if (_self._operator.type == '<?php echo ((is_array($_tmp=@USER_TYPE_MANAGER)) ? $this->_run_mod_handler('escape', true, $_tmp, 'javascript') : smarty_modifier_escape($_tmp, 'javascript')); ?>
') {
                                           location.href = '?p=pagemanager&t=pagebackendcontract&m=' + JSON.stringify({ a: 5, b: 8 });
                                         } else {
                                           location.href = '?p=pageadmin&t=pagebackendcontract&m=' + JSON.stringify({ a: 5, b: 8 });
                                         }
                                       };
  
  
  MiscUtils.sort(this._contracts, ['orderType']);
  for(var i = 0, il = this._contracts.length; i < il; i++) {
    var c = this._contracts[i];
    
    tr = this._gui.result.insertRow(-1);
    new ITableRowContract(tr, c, {callbackFunc: function() { _self._createElements(); }, operator: this._operator  });
  }
};
